﻿<!DOCTYPE html>
<html lang="en">
<head profile="http://a9.com/-/spec/opensearch/1.1/">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="./site.css" rel="stylesheet">
<title>mime</title>
</head>
<body>
<div class="container">
    <h2 id="pkg-overview">package mime</h2>
    <p><code>import "mime"</code>
    <p>mime实现了MIME的部分规定。</p>
    <h3 id="pkg-index" class="section-header">Index <a class="permalink" href="#pkg-index">&para;</a></h3>
    <a href="../main.html"><h3>返回首页</h3></a>
		</br>
        <li><a href="#AddExtensionType">func AddExtensionType(ext, typ string) error</a></li>
        <li><a href="#FormatMediaType">func FormatMediaType(t string, param map[string]string) string</a></li>
        <li><a href="#ParseMediaType">func ParseMediaType(v string) (mediatype string, params map[string]string, err error)</a></li>
        <li><a href="#TypeByExtension">func TypeByExtension(ext string) string</a></li>
    </ul>
    <h3 id="AddExtensionType">func <a title="View Source" href="https://github.com/golang/go/blob/master/src/mime/type.go?name=release#56">AddExtensionType</a> <a class="permalink" href="#pkg-index">&para;</a></h3>
    <pre class="funcdecl">func AddExtensionType(ext, typ <a href="builtin.htm#string">string</a>) <a href="builtin.htm#error">error</a></pre>
    <p>函数将扩展名和mimetype建立偶联；扩展名应以点号开始，例如".html"。</p>
    <h3 id="FormatMediaType">func <a title="View Source" href="https://github.com/golang/go/blob/master/src/mime/mediatype.go?name=release#21">FormatMediaType</a> <a class="permalink" href="#pkg-index">&para;</a></h3>
    <pre class="funcdecl">func FormatMediaType(t <a href="builtin.htm#string">string</a>, param map[<a href="builtin.htm#string">string</a>]<a href="builtin.htm#string">string</a>) <a href="builtin.htm#string">string</a></pre>
    <p>函数根据<a href="http://tools.ietf.org/html/rfc2045">RFC 2045</a>和 <a href="http://tools.ietf.org/html/rfc2616">RFC 2616</a>的规定将媒体类型t和参数param连接为一个mime媒体类型，类型和参数都采用小写字母。任一个参数不合法都会返回空字符串。</p>
    <h3 id="ParseMediaType">func <a title="View Source" href="https://github.com/golang/go/blob/master/src/mime/mediatype.go?name=release#101">ParseMediaType</a> <a class="permalink" href="#pkg-index">&para;</a></h3>
    <pre class="funcdecl">func ParseMediaType(v <a href="builtin.htm#string">string</a>) (mediatype <a href="builtin.htm#string">string</a>, params map[<a href="builtin.htm#string">string</a>]<a href="builtin.htm#string">string</a>, err <a href="builtin.htm#error">error</a>)</pre>
    <p>函数根据<a href="http://tools.ietf.org/html/rfc1521">RFC 1521</a>解析一个媒体类型值以及可能的参数。媒体类型值一般应为Content-Type和Conten-Disposition头域的值（参见<a href="http://tools.ietf.org/html/rfc2183">RFC 2183</a>）。成功的调用会返回小写字母、去空格的媒体类型和一个非空的map。返回的map映射小写字母的属性和对应的属性值。</p>
    <h3 id="TypeByExtension">func <a title="View Source" href="https://github.com/golang/go/blob/master/src/mime/type.go?name=release#45">TypeByExtension</a> <a class="permalink" href="#pkg-index">&para;</a></h3>
    <pre class="funcdecl">func TypeByExtension(ext <a href="builtin.htm#string">string</a>) <a href="builtin.htm#string">string</a></pre>
    <p align="left">函数返回与扩展名偶联的MIME类型。扩展名应以点号开始，如".html"。如果扩展名未偶联类型，函数会返回""。</p>
    <p align="left">内建的偶联表很小，但在unix系统会从本地系统的一或多个mime.types文件（参加下表）进行增补。</p>
    <pre>/etc/mime.types
/etc/apache2/mime.types
/etc/apache/mime.types</pre>
    <p>Windows系统的mime类型从注册表获取。文本类型的字符集参数默认设置为"utf-8"。</p>
</div>
</body>
</html>
